package com.xiaohuang.controller

import java.util

import com.xiaohuang.dao.{Testmapper, Xiaoming}
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.core.env.Environment
import org.springframework.ui.Model
import org.springframework.web.bind.annotation.{RequestMapping, RequestMethod, RestController}
import org.springframework.web.servlet.ModelAndView

import scala.collection.immutable.HashMap

/**
  * Created by Administrator on 2017/6/15.
  */
@RestController
class firstController {
  @Autowired
  var testmapper:Testmapper = _

  @Autowired
  var xiaoming:Xiaoming= _

  @Autowired
  var env: Environment = _;

  @RequestMapping(value = Array("/helloword"), method = Array(RequestMethod.GET))
  def helloword(mode:Model) = {
    mode.addAttribute("name","helloword")
    println(mode+"2q122swws")
    new ModelAndView("xiaoming")

  }


  @RequestMapping(value = Array("/testp"), method = Array(RequestMethod.GET))
  def testproperties(): String = {
    env.getProperty("testscala");
  }

  @RequestMapping(value = Array("/test"), method = Array(RequestMethod.GET))
  def testList(): List[Int] = {
    val list =  List(1,2,3)
    list.foreach(x => println(x))
    list
  }
}
